package com.itheima.homework.uuid;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class ClientPto {
    public static void main(String[] args) throws IOException {
        int i = 0;
        while (i < 20) {
            Socket socket = new Socket(InetAddress.getLocalHost(), 44444);
            BufferedInputStream bufferedInputStream = new BufferedInputStream(
                    new FileInputStream(new File("Day15_Socket\\lajiao.jpg")));
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(socket.getOutputStream());

            int b;
            while ((b = bufferedInputStream.read()) != -1) {
                bufferedOutputStream.write(b);
            }
            bufferedOutputStream.flush();
            bufferedInputStream.close();
            socket.shutdownOutput();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String s = bufferedReader.readLine();
            System.out.println(s);
            socket.close();
            i++;
        }
    }
}
